package com.bibi.hanshunping;

public class Exec04 {
    public static void main(String[] args) {
        // 判断一个数是否为水仙花数: 3位数的各个位置上的数字的立方和等于其本身
        // 如: 153 = 1 * 1 * 1 + 5 * 5 * 5 + 3 * 3 * 3

        // 获取个十百位上的数子
        int num = 153;
        int bai = num / 100;
        int shi = (num / 10) - bai * 10;
        int ge = num - bai * 100 - shi * 10;

        System.out.println("百" + bai + "十位" + shi + "个位" + ge);

        int total = shi * shi * shi + bai * bai * bai + ge * ge * ge;
        if (num == total) {
            System.out.println(num + "是水仙花数");
        } else {
            System.out.println(num + "不是水仙花数");
        }
    }
}
